package com.ruoyi.training.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.training.dto.NoticeReceiveDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.training.domain.NoticeReceive;
import com.ruoyi.training.service.INoticeReceiveService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 通知接收Controller
 * 
 * @author lqx
 * @date 2025-10-24
 */
@RestController
@RequestMapping("/noticeReceive")
public class NoticeReceiveController extends BaseController
{
    @Autowired
    private INoticeReceiveService noticeReceiveService;

    /**
     * 查询通知接收列表
     */
    @RequiresPermissions("training:noticeReceive:list")
    @GetMapping("/list")
    public TableDataInfo list(NoticeReceive noticeReceive)
    {
        startPage();
        List<NoticeReceive> list = noticeReceiveService.selectNoticeReceiveList(noticeReceive);
        return getDataTable(list);
    }

    /**
     * 学员查询门户班级通知接收列表
     * lqx
     */
//    @RequiresPermissions("training:noticeReceive:list")
    @GetMapping("/listByStudentIdAndClassId")
    public TableDataInfo listByStudentIdAndClassId(NoticeReceive noticeReceive)
    {
        startPage();
        List<NoticeReceiveDto> list = noticeReceiveService.selectNoticeReceiveListByStudentIdAndClassId(noticeReceive);
        return getDataTable(list);
    }

    /**
     * 导出通知接收列表
     */
    @RequiresPermissions("training:noticeReceive:export")
    @Log(title = "通知接收", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NoticeReceive noticeReceive)
    {
        List<NoticeReceive> list = noticeReceiveService.selectNoticeReceiveList(noticeReceive);
        ExcelUtil<NoticeReceive> util = new ExcelUtil<NoticeReceive>(NoticeReceive.class);
        util.exportExcel(response, list, "通知接收数据");
    }

    /**
     * 获取通知接收详细信息
     */
    @RequiresPermissions("training:noticeReceive:query")
    @GetMapping(value = "/{noticeReceiveId}")
    public AjaxResult getInfo(@PathVariable("noticeReceiveId") String noticeReceiveId)
    {
        return success(noticeReceiveService.selectNoticeReceiveByNoticeReceiveId(noticeReceiveId));
    }

    /**
     * 新增通知接收
     */
    @RequiresPermissions("training:noticeReceive:add")
    @Log(title = "通知接收", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NoticeReceive noticeReceive)
    {
        return toAjax(noticeReceiveService.insertNoticeReceive(noticeReceive));
    }

    /**
     * 修改通知接收
     */
    @RequiresPermissions("training:noticeReceive:edit")
    @Log(title = "通知接收", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NoticeReceive noticeReceive)
    {
        return toAjax(noticeReceiveService.updateNoticeReceive(noticeReceive));
    }

    /**
     * 删除通知接收
     */
    @RequiresPermissions("training:noticeReceive:remove")
    @Log(title = "通知接收", businessType = BusinessType.DELETE)
	@DeleteMapping("/{noticeReceiveIds}")
    public AjaxResult remove(@PathVariable String[] noticeReceiveIds)
    {
        return toAjax(noticeReceiveService.deleteNoticeReceiveByNoticeReceiveIds(noticeReceiveIds));
    }
}
